package com.demo.service.impl;

import com.demo.entity.Record;
import com.demo.mapper.RecordMapper;
import com.demo.service.RecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Ymj
 * @since 2020-11-23
 */
@Service
public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements RecordService {

    private RecordMapper recordMapper;

    @Autowired
    public void setRecordMapper(RecordMapper recordMapper) {
        this.recordMapper = recordMapper;
    }

    @Override
    public Long findTotalsByP_id(@Param("p_id") Long p_id){
        return recordMapper.findTotalsByP_id(p_id);

    }
    @Override
    public List<Record> findByPageByP_id(@Param("pageNow") Integer pageNow, @Param("pageSize") Integer pageSize, @Param("p_id") Long p_id){
        int start = (pageNow - 1) * pageSize;
        return recordMapper.findByPageByP_id(start, pageSize,p_id);
    }
    @Override
    public Long findTotalsByA_id(@Param("a_id") Long a_id){
        return recordMapper.findTotalsByA_id(a_id);

    }
    @Override
    public List<Record> findByPageByA_id(@Param("pageNow") Integer pageNow, @Param("pageSize") Integer pageSize, @Param("a_id") Long a_id){
        int start = (pageNow - 1) * pageSize;
        return recordMapper.findByPageByA_id(start, pageSize,a_id);
    }


    @Override
    public List<Record> findByPage(Integer pageNow, Integer pageSize) {
        int start = (pageNow - 1) * pageSize;
        return recordMapper.findByPage(start, pageSize);
    }

    @Override
    public List<Record> findAll() {
        return recordMapper.findAll();
    }

}
